package com.aaa.qy127.controller;


import com.aaa.qy127.entity.ChuKu;
import com.aaa.qy127.service.ChuKuService;
import com.aaa.qy127.util.CodeAndMsg;
import com.aaa.qy127.util.Result;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RequestMapping("/chuKu")
@RestController
public class ChuKuController {

    @Resource(name = "chuKuServiceImpl")
    private ChuKuService chuKuService;

    /**
     * 查询 所有的出库信息并分页 显示
     * @param chuKu
     * @return
     */
    @RequestMapping("/selectCk")
    public Result selectCk(ChuKu chuKu){
        //System.out.println(chuKu.getOverDate());
        Result allCK = chuKuService.getAllCK(chuKu);
        return allCK;
    }

    /**
     * 查询所有的出库详情信息， 并分页
     * @param chuKu
     * @return
     */
    @RequestMapping("/selectAllChuKu")
    public Result selectAllChuKu(ChuKu chuKu){
        Result allChuKu = chuKuService.getAllChuKu(chuKu);
        return allChuKu;
    }

    /**
     * 插入一条 出库信息 并 把 出库详情 添加进去
     * @param totalprice
     * @param totalcount
     * @param jsr
     * @param chukuxinxi
     * @param request
     * @return
     */
    @RequestMapping("/addChuKu")
    public CodeAndMsg addChuKu(String totalprice, String totalcount, String jsr, String chukuxinxi, HttpServletRequest request){
        /*System.out.println(chukuxinxi);
        System.out.println(totalprice);
        System.out.println(totalcount);
        System.out.println(jsr);
        List<Map> parse = (List<Map>)JSON.parse(chukuxinxi);*/
        CodeAndMsg codeAndMsg = chuKuService.addChuKu(totalprice, totalcount, jsr, chukuxinxi, request);
        return codeAndMsg;
    }

}
